<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>删除元素</title>
</head>
<style type="text/css">
    span{
        color: white;
        padding: 8px;
        margin: 5px;
        float: left;
    }
    .green{
        background-color: green;
    }
    .blue{
        background-color: blue;
    }
</style>
<body>
    <h3>删除元素</h3>
    <span class="green">jquery<a>删除</a></span>
    <span class="blue">javase</span>
    <span class="green">http协议</span>
    <span class="blue">servlet</span>
</body>
<!-- 
    删除元素
        remove()
            删除元素及其对应的子元素，标签和内容一起删除
            指定元素.remove();
        empty()
            清空元素内容，保留标签
            指定元素.empty();
-->
<script src="js/jquery-3.7.1.js"></script>
<script type="text/javascript">
    // 删除元素
    $(".green").remove()
    $(".blue").empty()
</script>

</html>